Skip to content

Conversation

@dacoburn
Copy link
Collaborator

Filename stripping logic for file upload keys was incorrectly removing leading dots from filenames (e.g., .socket.facts.json became socket.facts.json) and failed when given filenames without path separators. This caused issues when uploading dotfiles or files specified with relative/absolute paths, resulting in incorrect key names or exceptions.

Root Cause

The bug was caused by:

  • Using lstrip("./") on file keys, which stripped all leading dots and slashes, not just ./ prefixes.
  • Unconditionally splitting file paths with rsplit("/", 1) without checking for the presence of a path separator, causing unpack errors for filenames without /.
  • Not normalizing all path variants to a consistent, relative key as required by the API.

Fix

  • Updated the logic to only remove ./ and ../ prefixes and leading slashes, while preserving leading dots in filenames.
  • Added a check before splitting file paths to avoid unpack errors.
  • Ensured all keys are normalized to relative paths, skipping directories, and handling Windows drive letters.
  • Added comprehensive tests to verify correct behavior for all path scenarios.

Public Changelog

  • Fixed handling of dotfiles (files starting with '.') to preserve their names correctly during file uploads
  • Resolved errors that occurred when uploading files specified without directory paths
  • Improved file path normalization to ensure consistent relative paths across different operating systems, including Windows

@dacoburn dacoburn requested a review from a team as a code owner October 17, 2025 00:59
@dacoburn dacoburn requested review from BarrensZeppelin and tmpvar and removed request for a team October 17, 2025 00:59
@dacoburn dacoburn added the product changelog Any public-facing change in the product's features label Oct 17, 2025
@github-actions
Copy link

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketdev==3.0.14.dev1

@dacoburn dacoburn merged commit 4d3d213 into main Oct 17, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product changelog Any public-facing change in the product's features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants